package cn.bossfriday.im.common.enums.user;

import lombok.Getter;

/**
 * UserStateType
 *
 * @author chenx
 */
public enum UserStateType {

    /**
     * 正常
     */
    NORMAL(0, "normal"),

    /**
     * 封禁
     */
    LOCKED(1, "locked"),

    /**
     * 删除
     */
    DELETED(2, "deleted"),
    ;

    @Getter
    private int code;

    @Getter
    private String name;

    UserStateType(int code, String name) {
        this.code = code;
        this.name = name;
    }

    /**
     * getByCode
     *
     * @param code
     * @return
     */
    public static UserStateType getByCode(int code) {
        for (UserStateType entry : UserStateType.values()) {
            if (entry.getCode() == code) {
                return entry;
            }
        }

        return null;
    }
}
